package com.nondo.rdp.finance.repository.course;

import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.nondo.rdp.core.common.StatusConstant;
import com.nondo.rdp.finance.domain.course.SectionComment;

public interface SectionCommentRepository extends JpaRepository<SectionComment, Long>,
		JpaSpecificationExecutor<SectionComment> {
	@Query("select a from SectionComment a where a.id=:id and delFlag = '" + StatusConstant.DEL_FLAG_NORMAL + "'")
	Optional<SectionComment> findOne(@Param("id") int id);

	@Modifying
	@Query("update SectionComment set delFlag='" + StatusConstant.DEL_FLAG_DELETE + "' where id = ?1")
	void deleteById(Long id);

	SectionComment save(SectionComment sectionComment);

	@Query("select a from SectionComment a where a.section.id=:sid and delFlag = '" + StatusConstant.DEL_FLAG_NORMAL + "'")
	List<SectionComment> getCommentListBySid(@Param("sid") long sid);

}
